﻿namespace MatrixField
{
    using System;
    using System.Linq;

    public class Execution
    {
        public static int ReadInput()
        {
            Console.Write("Enter a positive number [1;100]: ");
            string input = Console.ReadLine();
            int n = 0;
            while (!int.TryParse(input, out n) || n < 0 || n > 100)
            {
                Console.WriteLine("You haven't entered a correct positive number");
                input = Console.ReadLine();
            }

            n = int.Parse(input);
            return n;
        }

        private static void Main(string[] args)
        {
            int n = ReadInput();
            Matrix matrix = new Matrix(n);
            //// matrix.ValueCell = 1;

            MatrixFill.FillMatrix(matrix);
            if (matrix.ValueCell < matrix.Size * matrix.Size)
            {
                matrix.Row = 2;
                matrix.Col = 1;
                matrix.ValueCell++;
                MatrixFill.FillMatrix(matrix);
            }

            Console.WriteLine(matrix.ToString());
        }
    }
}